package com.ruoyi.project.distribute.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.distribute.domain.HosCompany;
import com.ruoyi.project.distribute.domain.HosDrug;
import com.ruoyi.project.distribute.service.IHosDrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author anran
 */
@RestController
@RequestMapping("/distribute/drug")
public class HosDrugController extends BaseController
{
    @Autowired
    private IHosDrugService hosDrugService;

    /**
     * 查询生产厂家信息
     */
    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('distribute:drug:list')")
    public TableDataInfo list(HosDrug hosDrug)
    {
        startPage();
        List<HosDrug> list = hosDrugService.selectHosDrugList(hosDrug);
        return getDataTable(list);
    }

    /**
     * 删除药品信息
     */
    @PreAuthorize("@ss.hasPermi('distribute:drug:remove')")
    @Log(title = "药品信息",businessType = BusinessType.DELETE)
    @DeleteMapping("/{drugIds}")
    public AjaxResult remove(@PathVariable Long[] drugIds)
    {
        return toAjax(hosDrugService.deleteHosDrugByID(drugIds));
    }

    /**
     * 导出药品信息
     */
    @PreAuthorize("@ss.hasPermi('distribute:drug:export')")
    @Log(title = "药品信息",businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HosDrug hosDrug)
    {
        List<HosDrug> list = hosDrugService.selectHosDrugList(hosDrug);
        ExcelUtil<HosDrug> util = new ExcelUtil<>(HosDrug.class);
        return util.exportExcel(list,"药品信息");
    }

}
